/*
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.jaytter.ui.panels.impl;

import java.net.URL;
import javax.swing.JLabel;
import twitter4j.DirectMessage;
import twitter4j.Status;

/**
 * Mostra um tweet
 */
public class GenericSingleTweetPanel extends javax.swing.JPanel {

    /** Creates new form Tweet */
    public GenericSingleTweetPanel() {
        initComponents();
    }

    public GenericSingleTweetPanel(Status status) {
        initComponents();
        loadProfileImage(status.getUser().getProfileImageURL());
        System.out.println(status.getUser().getName() + ": " + status.getText());
        message.setText("<html><p>" + status.getText() + "</p></html>");
    }

    public GenericSingleTweetPanel(DirectMessage status) {
        initComponents();
        loadProfileImage(status.getRecipient().getProfileImageURL());
        message.setText("<html><p>" + status.getText() + "</p></html>");
    }

    private void loadProfileImage(URL source) {

        avatar.setText("<html><img src=\"" + source.toString() + "\" width=\"70px\" height=\"70px\"/></html>");
    }

    public JLabel getAvatar() {
        return avatar;
    }

    public JLabel getMessage() {
        return message;
    }

    public void setAvatar(JLabel avatar) {
        this.avatar = avatar;
    }

    public void setMessage(JLabel message) {
        this.message = message;
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        message = new javax.swing.JLabel();
        avatar = new javax.swing.JLabel();

        setBackground(new java.awt.Color(206, 252, 144));
        setLayout(new java.awt.BorderLayout());

        message.setText("<html><p>O @zanata_arnos dissecou o Peñarol no Blog do Mauro Cezar. Leitura obrigatória para quem verá a final hoje: http://bit.ly/geFuSC.</p></html>");
        message.setVerticalAlignment(javax.swing.SwingConstants.TOP);
        message.setPreferredSize(new java.awt.Dimension(60, 40));
        add(message, java.awt.BorderLayout.CENTER);

        avatar.setAlignmentY(0.0F);
        avatar.setPreferredSize(new java.awt.Dimension(70, 60));
        add(avatar, java.awt.BorderLayout.LINE_START);
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel avatar;
    private javax.swing.JLabel message;
    // End of variables declaration//GEN-END:variables
}
